/**
 * 
 * @author Jonathan
 *
 */
public class CorrelatedAttribute {
	private String correlation;
	private String attribute;
	
	public CorrelatedAttribute(String correlation, String attribute) {
		this.setCorrelation(correlation);
		this.setAttribute(attribute);
	}

	public String getCorrelation() {
		return correlation;
	}

	public void setCorrelation(String correlation) {
		this.correlation = correlation;
	}

	public String getAttribute() {
		return attribute;
	}

	public void setAttribute(String attribute) {
		this.attribute = attribute;
	}
	
	/**
	 * Parses "s" and returns a CorrelatedAttribute corresponding to
	 * s or null if s is not a CorrelatedAttribute.
	 * @param s
	 * @return
	 */
	public static CorrelatedAttribute parseCorrelatedAttribute(String s) {
		if (s == null)
		{
			System.out.println("CorrelatedAttribute unable to parse null string.");
			throw new RuntimeException("CorrelatedAttribute unable to parse null string.");
		}
		
		//if (Interpreter.DEBUG) System.out.println("CorrelatedAttribute parsing \"" + s + "\".");
		String[] parts = s.split("\\.");
		if (parts == null || parts.length != 2)
			return null;
		return new CorrelatedAttribute(parts[0], parts[1]);
	}
}
